package edu.uoc.tfc.web.tags;



import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;



public class DataTablesSearchButtonTag extends EmktBaseTag {


 
    private static final long serialVersionUID = 1L;



    private String tableName;
    private String label;
    private boolean startHidden = false;


    
    public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}



    public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}



	public boolean isStartHidden() {
	    return startHidden;
    }

	public void setStartHidden(boolean startHidden) {
	    this.startHidden = startHidden;
    }



	public int doStartTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			this.writeButton(out);
		} catch (Exception ex) {
			throw new JspException(ex);
		}
		return SKIP_BODY;
	}



	private void writeButton(JspWriter out) throws Exception {
		String theId = escapeNameForJqueryId(getTableName());

		write(out,"<button id=\"" + theId + "-search\" class=\"emkt-filter-button btn emkt-buscar-ajax");
		if (isStartHidden())
			out.print(" hide");
		write(out,"\" data-tablename=\"" + getTableName() + "\">");
		write(out,"<i class=\"icon-search\"></i> " + getMessage(getLabel(), null));
		write(out,"</button>");
	}



}
